<template>
    <!--为echarts准备一个具备大小的容器dom-->
    <div id="main" style="width: 1400px;height: 700px;"></div>
</template>
<script>
    import {amountofbusiness} from '../api'
    import echarts from 'echarts'
    export default {
        name: '',
        data() {
            return {
                charts: '',
            /*  opinion: ["1", "3", "3", "4", "5"],*/
                opinionData: [2005, 200, 400, 800, 500, 4000]
            }
        },
        async created() {
            let {data:BaseRefault} = await amountofbusiness()
            console.info(BaseRefault.data)
            console.info(this.opinionData)

            this.opinionData = BaseRefault.data

            console.info(this.opinionData)
            //  this.$router.push("/welcome")
            this.$nextTick(function() {
                this.drawLine('main')
            })
        },
        computed: {

        },
        methods: {
            drawLine(id) {
                this.charts = echarts.init(document.getElementById(id))
                this.charts.setOption({
                    tooltip: {
                        trigger: 'axis'
                    },
                    legend: {
                        data: ['2月收益']
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
 
                    toolbox: {
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    xAxis: {
                        type: 'category',
                        boundaryGap: false,
                    data: ["2月1-5日","2月5-10日","2月10-15日","2月15-20日","2月20-25日","2月25-30日"]
                    
                    },
                    yAxis: {
                        type: 'value'
                    },
 
                    series: [{
                        name: '2月收益',
                        type: 'line',
                        stack: '总量',
                        data: this.opinionData,
                        areaStyle: {normal:{}},
                        itemStyle: {
                              normal: {
                                  color: new echarts.graphic.LinearGradient(
                                      0, 0, 0, 1,
                                      [
                                          {offset: 0, color: 'red'},
                                          {offset: 0.5, color: 'pink'},
                                          {offset: 1, color: '#ddd'}
                                      ]
                                  )
                              }
                          }
                    }]
                })
            }
        },
        //调用
        mounted() {
            
        }
    }
</script>
<style scoped>
    * {
        margin: 0;
        padding: 0;
        list-style: none;
    }
</style>